home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue33 / system / IDERoller.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-04-03  |  1.4 KB  |  55 lines

  1. unit IDERoller;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, ExtCtrls, IDEMouseWheel;
  8.  
  9. implementation
  10.  
  11. var
  12.     Timer: UINT;
  13.  
  14. procedure ScrollCodeEditor (Editor: TWinControl; Count: Integer);
  15. var
  16.     Idx, Code: Integer;
  17. begin
  18.     if Count < 0 then Code := sb_LineUp else Code := sb_LineDown;
  19.     for Idx := 0 to Abs (Count) - 1 do SendMessage (Editor.Handle, wm_VScroll, Code, 0);
  20. end;
  21.  
  22. procedure WheelSpin (Count: Integer);
  23. var
  24.     Form: TForm;
  25.     Editor: TWinControl;
  26. begin
  27.     Form := Wheel.ActiveForm;
  28.     { Sanity check time.... }
  29.     if (Form <> Nil) and (Form.ClassName = 'TEditWindow') then begin
  30.         Editor := TWinControl (Form.FindComponent ('Editor'));
  31.         if Editor <> Nil then ScrollCodeEditor (Editor, Count);
  32.     end;
  33. end;
  34.  
  35. procedure TimerTick (Wnd: hWnd; Msg, Event, dwTime: UINT); stdcall;
  36. var
  37.     Form: TForm;
  38. begin
  39.     Form := Screen.ActiveForm;
  40.     if (Form <> Nil) and (Form.ClassName = 'TEditWindow') then begin
  41.         Wheel.ActiveForm := Form;
  42.         Wheel.OnWheelSpin := WheelSpin;
  43.     end
  44.     else Wheel.ActiveForm := Nil;
  45. end;
  46.  
  47. initialization
  48.     if Wheel.WheelPresent then Timer := SetTimer (0, 0, 500, @TimerTick);
  49. finalization
  50.     if Wheel.WheelPresent then begin
  51.         Wheel.ActiveForm := Nil;
  52.         KillTimer (0, Timer);
  53.     end;
  54. end.
  55.